package cn.fourhundredandeighteen.view.Component;

import javax.swing.*;
import java.awt.*;

public class Button extends JButton {
    public static final int OKBUTTON = 0;
    public static final int CANCELBUTTON = 1;

    public Button() {
        initOKButton();
    }

    public Button(String text) {
        super(text);
        initOKButton();
    }

    public Button(int type) {
        if (type == CANCELBUTTON) {
            initCancelBuuton();
        } else {
            initOKButton();
        }
    }

    public Button(String text, int type) {
        super(text);
        if (type == CANCELBUTTON) {
            initCancelBuuton();
        } else {
            initOKButton();
        }
    }

    // 确认按钮样式
    private void initOKButton() {
        this.setForeground(Color.white);
        this.setBackground(new Color(0, 150, 137));
    }

    // 取消按钮样式
    private void initCancelBuuton() {
        this.setBackground(Color.white);
        this.setForeground(new Color(250, 60, 60));
    }

}
